package com.yijian.oj.judge.codesandbox;

import com.yijian.oj.judge.codesandbox.model.ExecuteCodeRequest;
import com.yijian.oj.judge.codesandbox.model.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * 代理模式创建代码沙箱
 * @author ItJianGe
 * @data 2024/3/25 9:02
 */
@Slf4j
public class CodeSandBoxProxy implements CodeSandBox {

    private final CodeSandBox codeSandBox;

    public CodeSandBoxProxy(CodeSandBox codeSandBox) {
        this.codeSandBox = codeSandBox;
    }

    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest codeRequest) {
        log.info(codeRequest.getInput().toString());
        ExecuteCodeResponse executeCodeResponse = codeSandBox.executeCode(codeRequest);
        log.info(executeCodeResponse.getMessage());
        return executeCodeResponse;
    }
}
